<TMPL_INCLUDE name=../header.html>
<div id=content_area>

<div id="left_content_area">
<h3>Manage Salutations</h3>
<table width="100%" border="0">
    <TR height="30px">
        <TD width=20%>Salutation</TD>
        <TD><input type="text" id=salutation onClick="$('salutation_comment').innerHTML = '';" style="width:100%;"></TD>
        <!--<TD id=salutation_comment class="ResultText"></TD>-->
    </TR>
    <TR>
        <TD></TD>
        <TD><input type="button" value="create" onClick="create_new_salutation();"></TD>
    </TR>
    <TR>
        <TD></TD>
        <TD id=salutation_list>
            <TMPL_INCLUDE name="./Salutations_List.html">
        </TD>
    </TR>
</table>
</div>

<!--<div id="right_content_area">

</div>-->


</div>
<TMPL_INCLUDE name=../footer.html>

<script>
// $('salutation').focus() = true;

URL     = "Settings.pl";

function create_new_salutation()
{
    if ($('salutation').value == '') {
        $('salutation_comment').innerHTML = "please provide salutation";
    }
    else {
        PARAMS  = "action=create_new_salutation&salutation=" + $('salutation').value;

        new Ajax.Updater ('salutation_list', URL, {
                        parameters: PARAMS,
                        asynchronous: true,
                        onLoading: PrintStatus('salutation_list', "Saving..."),
                        onComplete: ClearStatus,
                        });

        update_salutation_list();
    }
    $('salutation').value = '';
}

function update_salutation_list()
{
    PARAMS  = "action=get_salutation_list";

    new Ajax.Updater ('salutation_list', URL, {
                        parameters: PARAMS,
                        asynchronous: true,
                        onLoading: PrintStatus('salutation_list', "Reloading..."),
                        onComplete: ClearStatus,
                        });
}

function edit_salutation(salutation_id)
{
    var salutation_name  = 'salutation_' + salutation_id;
    var salutation_value = $(salutation_name).value;
//     alert('sal_name, sal_val = ' + salutation_name + ', ' + salutation_value);
//     exit;

    PARAMS  = "action=edit_salutation&salutation_id=" + salutation_id + "&salutation=" + salutation_value;

    new Ajax.Updater ('salutation_list', URL, {
                    parameters: PARAMS,
                    asynchronous: true,
                    onLoading: PrintStatus('salutation_list', "Saving..."),
                    onComplete: ClearStatus,
                    });

    update_salutation_list();
}

$('salutation_comment').innerHTML   = "";
$('salutation').value               = "";

</script>